/*
 * @message: 描述
 * @Author: Roy
 * @Email: @163.com
 * @Github: @163.com
 * @Date: 2021-11-20 14:25:57
 * @LastEditors: Roy
 * @LastEditTime: 2021-11-25 15:24:18
 * @Deprecated: 否
 * @FilePath: /train-ticket/src/pages/ticket/store/reducer.js
 */
import * as actionTypes from './actionTypes'
const defaultState = {
    departDate: Date.now(),//出发日期
    arriveDate: Date.now(),//到达日期
    departTimeStr: null,//出发时间字符串
    arriveTimeStr: null,//到达时间字符串
    departStation: null,
    arriveStation: null,
    trainNumber: null,//车次
    durationStr: null,//运行时间
    tickets: [],
    isScheduleVisible: false,
    searchParsed: false,
};

// eslint-disable-next-line import/no-anonymous-default-export
export default (state = defaultState, action) => {
    let newState = JSON.parse(JSON.stringify(state));
    switch (action.type) {
        case actionTypes.ACTION_SET_DEPART_DATE:
            newState.departDate = action.payload;
            return newState;
        case actionTypes.ACTION_SET_ARRIVE_DATE:
            newState.arriveDate = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DEPART_TIME_STR:
            newState.departTimeStr = action.payload;
            return newState;
        case actionTypes.ACTION_SET_ARRIVE_TIME_STR:
            newState.arriveTimeStr = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DEPART_STATION:
            newState.departStation = action.payload;
            return newState;
        case actionTypes.ACTION_SET_ARRIVE_STATION:
            newState.arriveStation = action.payload;
            return newState;
        case actionTypes.ACTION_SET_TRAIN_NUMBER:
            newState.trainNumber = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DURATION_STR:
            newState.durationStr = action.payload;
            return newState;
        case actionTypes.ACTION_SET_TICKETS:
            newState.tickets = action.payload;
            return newState;
        case actionTypes.ACTION_SET_IS_SCHEDULE_VISIBLE:
            newState.isScheduleVisible = action.payload;
            return newState;
        case actionTypes.ACTION_SET_SEARCH_PARSED:
            newState.searchParsed = action.payload;
            console.log(action.payload);
            return newState;
        default:
            break;
    }
    return state;

};
